package com.mdd.admin.controller.jiaz.engineer;

import com.mdd.admin.service.jiaz.IEngineerApplyService;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validate.engineer.EngineerApplyAuditValidate;
import com.mdd.common.validate.engineer.EngineerApplySearchValidate;
import com.mdd.common.validator.annotation.IDMust;
import com.mdd.common.vo.engineer.EngineerApplyAdDetailVo;
import com.mdd.common.vo.engineer.EngineerApplyListedVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("api/engineer/apply")
@Api(tags = "师傅申请管理")
public class EngineerApplyController {

    @Resource
    IEngineerApplyService engineerApplyService;

    @GetMapping("/list")
    @ApiOperation("师傅申请列表")
    public AjaxResult<PageResult<EngineerApplyListedVo>> list(@Validated PageValidate pageValidate, @Validated EngineerApplySearchValidate searchValidate) {
        PageResult<EngineerApplyListedVo> list = engineerApplyService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation("师傅申请详情")
    public AjaxResult<EngineerApplyAdDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        EngineerApplyAdDetailVo vo = engineerApplyService.detail(id);
        return AjaxResult.success(vo);
    }

    @PostMapping("/audit")
    @ApiOperation("师傅申请审核")
    public AjaxResult<Object> audit(@Validated @RequestBody EngineerApplyAuditValidate auditValidate) {
        engineerApplyService.audit(auditValidate);
        return AjaxResult.success();
    }

}
